import React, { Component } from 'react';
import { NavBar, List, Modal, Input, Toast } from 'antd-mobile'
import "../styles/Shezhi.scss"
import * as service from "../api/index"


class Shezhi extends Component {
    constructor(props) {
        super(props);
        this.state = {
            add: ''
        };
        
    }
    async gai() {
        var res = await service.user_updatePassword()
        console.log(res);
    }
    async bian(value) {
        // console.log(value);
        this.setState({ add: value })
        var res = await service.user_bindusername()
        // console.log(res);
    }
    

    render() {
        return (
            <div className='shezhi'>
                <div className="top">
                    <NavBar onBack={() => { this.props.history.go(-1) }} ><p>设置</p></NavBar>
                </div>
                <List>
                    <List.Item onClick={() => {
                        Modal.confirm({
                            title: '设置用户名',
                            onConfirm: () => {
                                Toast.show({
                                    icon: 'success',
                                    content: '提交成功',
                                })
                                this.props.history.push({ pathname: '/index/my', state: this.state.add })
                            },
                            content: <Input
                                onChange={(value) => {
                                    // console.log(value);
                                    this.bian(value)

                                }}
                                placeholder='请输入用户名'
                            />
                        })
                    }}>
                        绑定用户名
                    </List.Item>
                    <List.Item onClick={() => {
                        Modal.confirm({
                            title: '更新密码',
                            content: <Input
                                placeholder='新密码'
                            />
                        })
                    }}>
                        修改密码
                    </List.Item>
                </List>
                <div className="btn">
                    <span onClick={() => { this.props.history.push('/login') }}>退出登录</span>
                </div>
            </div >
        );
    }
}

export default Shezhi;